.TH std::forward_iterator 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::forward_iterator \- std::forward_iterator

.SH Synopsis
   Defined in header <iterator>
   template< class I >

       concept forward_iterator =
           std::input_iterator<I> &&
           std::derived_from</*ITER_CONCEPT*/<I>,                         \fI(since C++20)\fP
   std::forward_iterator_tag> &&
           std::incrementable<I> &&

           std::sentinel_for<I, I>;

   This concept refines std::input_iterator by requiring that I also model
   std::incrementable (thereby making it suitable for multi-pass algorithms), and
   guaranteeing that two iterators to the same range can be compared against each
   other.

.SH Notes

   Unlike the LegacyForwardIterator requirements, the forward_iterator concept does not
   require dereference to return a reference.

.SH Example

   A minimum forward iterator.

 #include <cstddef>
 #include <iterator>

 struct SimpleForwardIterator
 {
     using difference_type = std::ptrdiff_t;
     using value_type = int;

     int operator*() const;

     SimpleForwardIterator& operator++();

     SimpleForwardIterator operator++(int)
     {
         auto tmp = *this;
         ++*this;
         return tmp;
     }

     bool operator==(const SimpleForwardIterator&) const;
 };

 static_assert(std::forward_iterator<SimpleForwardIterator>);

.SH See also

                          specifies that a type is an input iterator, that is, its
   input_iterator         referenced values can be read and it can be both pre- and
   (C++20)                post-incremented
                          (concept)
   bidirectional_iterator specifies that a forward_iterator is a bidirectional
   (C++20)                iterator, supporting movement backwards
                          (concept)
